package actions;

import java.awt.event.ActionEvent;

import frame.AwesomeFrame;

/**
 * 
 * Handle Toggling of Column Mode.
 * @author Ashley Polkinghorn
 *
 */
public class ColumnModeMenuAction extends AwesomeMenuAction {

	/**
	 * Frame that contains column mode flag
	 */
	private AwesomeFrame frame = null;
	private final String titleAddition=" -Column Mode";
	
	/**
	 * Create new Colulmn Mode Action
	 * @param name
	 * @param desc
	 */
	public ColumnModeMenuAction(String name, String desc) {
		super(name, desc);
	}

	/**
	 * Toggle column mode
	 */
	@Override
	public void actionPerformed(ActionEvent e) {
		// toggle
		if(frame == null)
			frame = getParentFrame(e);
		frame.isInColumnMode = !frame.isInColumnMode;
		if(frame.isInColumnMode)
		{
			frame.setTitle(frame.getTitle()+titleAddition);
		}
		else
		{
			frame.setTitle(frame.getTitle().replaceAll(titleAddition, ""));
		}
	}

}
